
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<html>
<head>
    <title>学员列表展示</title>
    <style>
        div{
            position: absolute;
            right: 6px;
            top: 38px;
        }
    </style>
    <script>

        function detail(sid) {
            location.href="student?method=selectOne&sid="+sid;

        }
        function update(sid) {
            location.href="student?method=updateShowStudent&sid="+sid;

        }
        function del(sid) {
            //提示框
            if (confirm("是否要删除?")){
                //请求后台servlet完成删除
                location.href="student?method=deleteStudent&sid="+sid;
            }

        }
        function toPage() {
            var currentPage = document.getElementById("currentPage").value;
            if (currentPage<1||currentPage>${page.totalPage}){
                alert("对不起,你输入的页码超出范围,请重新输入!!");
                return;
            }else{
                //请求服务器做分页查询
                location.href="student?method=findByPage&currentPage="+currentPage;
            }

        }
    </script>
</head>
<body>
<h2 align="right">欢迎${sessionScope.admin.username}登录!! 当前网站在线人数为${applicationScope.count}人</h2>

<table border="1" width="900px" cellpadding="10" cellspacing="0" align="center">
    <caption><h2>学员信息列表展示</h2></caption>
    <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
        <th>头像</th>
        <th>学历</th>
        <th>邮箱</th>
        <th>备注</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${page.list}" var="stu">
        <tr>
            <td>${stu.sid}</td>
            <td>${stu.sname}</td>
            <td>${stu.age}</td>
            <td>${stu.sex}</td>
            <td>
                  <img src="http://localhost:8080/pic/${stu.pic}"  width="50px" height="50px">
            </td>
            <td>${stu.degree}</td>
            <td>${stu.email}</td>
            <td>${stu.mark}</td>
            <td>
                <button onclick="detail(${stu.sid})">详情</button>
                <button onclick="update(${stu.sid})">修改</button>
                <button onclick="del(${stu.sid})">删除</button>
            </td>
        </tr>
    </c:forEach>
    <tr align="center">
        <td colspan="9">
            <span style="color:blue">共计${page.totalCount}条 ${page.currentPage}/${page.totalPage}</span>
            <a href="student?method=findByPage&currentPage=1">首页</a>
            <a href="student?method=findByPage&currentPage=${page.prePage}">上一页</a>
            <a href="student?method=findByPage&currentPage=${page.nextPage}">下一页</a>
            <a href="student?method=findByPage&currentPage=${page.totalPage}">尾页</a>
            跳转到第<input type="text" size="4" id="currentPage" name="currentPage">页
            <button onclick="toPage()">GO</button>
        </td>
    </tr>
</table>
<p align="center">
    <a href="addstudent.jsp">添加新学员</a>
</p>
<div>
    <a href="admin?method=logout">安全退出</a>
</div>
</body>
</html>
